package com.aclyyx.mi.display.action;

import android.graphics.Color;

import com.aclyyx.mi.display.Param;

public class FlashColor1 extends Action {

	private int r;
	private int g;
	private int b;

	public FlashColor1(Param param) {
		super(param);
	}

	@Override
	public void init() {
		r = 0;
		g = 100;
		b = 200;

		getParam().setX(getParam().displayWidth);
		getParam().setY(25);
	}

	@Override
	public void run() {
		Param p = getParam();
		long l = p.runtime;
		long h = l * 2;
		
		r = new Long(h%400).intValue();
		if (r > 200) {
			r = 200 - r + 200;
		}
		
		g = new Long(h%350).intValue();
		if (g > 175) {
			g = 175 - g + 175;
		}
		
		b = new Long(h%300).intValue();
		if (b > 150) {
			b = 150 - b + 150;
		}
		
		p.bcolor = Color.rgb(r, g, b);

		p.setX(new Long(p.displayWidth - l * 10 % (p.displayWidth + p.width)).intValue());
		p.setY(25);

		p.runtime++;
	}

}
